package com.geely.jdemo.inherit;

import org.junit.Test;

/**
 * 6.泛型类型的继承规则
 *
 * @param <T>
 */
public class Pair<T> {
    private T one;
    private T two;

    private static <T> void set(Pair<T> employeePair) {

    }

    class Employee {
    }

    class Work extends Employee {

    }

    @Test
    public void mainTest() {
        //Pair<Employee>和Pair<Work> workPair没有任何继承关系
        Pair<Work> workPair = new Pair<>();
        Pair<Employee> employeePair = new Pair<>();

//        Pair<Employee> employeePair2 = new Pair<Work>();//类型不匹配

        set(employeePair);
        set(workPair);
    }

    /**
     * 泛型类可以继承或者扩展其他泛型类，比如List和ArrayList
     *
     * @param <T>
     */
    private static class ExtendPair<T> extends Pair<T> {

    }
}
